package com.tuling.iocbeanlifecicle;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * Created by xsls on 2019/8/15.
 */
@Configuration

public class MainConfig2 {

	@Bean("car")
	public Car car(){

		Car car = new Car();
		car.setName("MainConfig2 firset" + Math.random());
		//car.setTank(tank());
		// 如果不去ioc 容器中拿   是不是每次都会创建新的
		// 都会先根据方法名  getBean("car")
		return car;
	}
	@Bean("car")
	public com.tuling.iocbeanlifecicle.car.Car  card(){

		com.tuling.iocbeanlifecicle.car.Car  car = new com.tuling.iocbeanlifecicle.car.Car ();
		car.setName("MainConfig2" + Math.random());
		//car.setTank(tank());
		// 如果不去ioc 容器中拿   是不是每次都会创建新的
		// 都会先根据方法名  getBean("car")
		return car;
	}

}
